package drawer2.figure;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class DrawingFrame extends JFrame
{
	public DrawingFrame()
	{
		super("Drawing Application");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		JComponent drawingCanvas = createDrawingCanvas();
		add(drawingCanvas, BorderLayout.CENTER);
		JToolBar toolbar = createToolbar();
		add(Toolbar, BorderLayout.NORTH);
	}

	private JComponent createDrawingCanvas()
	{
		JComponent drawingCanvas = new JPanel();
		drawingCanvas.setPreferredSize(new Dimesion(400,300));
		drawingCanvas.setBackground(Color.white);
		drawingCanvas.setBorder(BorderFactory.createEtchedBorder());
		return drawingCanvas;
	}
	
	private JToolBar createtoolbar()
	{
		JTooBar toolbar = new JToolBar();
		JButton ellipseButton = new JButton("Ellipse");
		toolbar.add(ellipseButton);
		JButton squareButton = new JButton("Square");
		toolbar.add(squareButton);
		JButton RectButton = new JButton("Rect");
		toolbar.add(RectButton);

		CanvasEditor CanvasEditor = new CanvasEditor(ellipseButton);
		ellipseButton.addActionListener(CanvasEditor);
		SquareButton.addActionListener(CanvasEditor);
		RectButton.addActionListener(CanvasEditor);

		return toolbar;
	}

	public static void main(String[] args)
	{
		DrawingFrame drawFrame = new DrawingFrame();
		drawFrame.pack();
		drawFrame.setVisible(true);
	}
}
